package com.zy.teacher.controller.front;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.netflix.discovery.converters.Auto;
import com.zy.commont.result.Result;
import com.zy.teacher.entity.EduCourse;
import com.zy.teacher.entity.vo.CourseWebVo;
import com.zy.teacher.entity.vo.OneChapter;
import com.zy.teacher.service.EduChapterService;
import com.zy.teacher.service.EduCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/eduservice/frontcourse")
@CrossOrigin
public class FrontCourseController {

    @Autowired
    private EduCourseService courseService;

    @Autowired
    private EduChapterService chapterService;

    //根据课程id查询课程详情信息
    @GetMapping("getFrontCourseInfo/{id}")
    public Result getFrontCourseInfo(@PathVariable String id) {
        //1 根据id查询课程基本信息
        CourseWebVo courseFrontInfo = courseService.getCourseInfoFrontId(id);

        //2 根据课程id查询课程大纲（章节和小节）
//        List<OneChapter> allChapterVideo = chapterService.getAllChapterVideo(id);

        return Result.ok().data("courseFrontInfo",courseFrontInfo);//data("chapterVideoList",allChapterVideo);
    }
    //课程分页列表
//    @GetMapping("getCourseFrontList/{page}/{limit}")
//    public Result getCourseFrontList(@PathVariable Long page,
//                                @PathVariable Long limit) {
//        Page<EduCourse> pageCourse = new Page<>(page,limit);
//        Map<String,Object> map = courseService.getFrontCourseList(pageCourse);
//        return Result.ok().data(map);
//    }

}
